<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src='../js/旧版本/react.development.js'></script>
    <script src='../js/旧版本/react-dom.development.js'></script>
    <script src='../js/旧版本/babel.min.js'></script>
    <script src='../js/旧版本/prop-types.js'></script>
</head>

<body>
    <div id="test"></div>
    <script type='text/babel'>
        class RefUse extends React.Component {
            myRef = React.createRef()
            myRef2 = React.createRef()
            showData = () => {
                alert(this.myRef.current.value)
            }
            showData2 = () => {
                alert(this.myRef2.current.value)
            }
            render() {
                return (
                    <div>
                        {/*<input type="text" ref={c => this.input1 = c} />*/}
                        <input type="text" ref={this.myRef} />
                        <button onClick={this.showData}>点击显示数据</button>
                        <input onBlur={this.showData2} type="text" ref={this.myRef2} />
                    </div>
                )
            }
        }

        ReactDOM.render(<RefUse />, document.querySelector("#test"))
    </script>
</body>

</html>